package com.hz.controller;

import com.hz.dao.UserOrderDao;
import com.hz.pojo.UserOrder;
import com.hz.service.impl.UserOrderServicImpl;
import com.hz.utils.MassageJsons;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/UserOrder")
public class UserOrderController {
    @Resource
    UserOrderDao userOrderDao;
    @Resource
    UserOrderServicImpl userOrderServic;

    /**
     * 获取所有订单信息包括查询分页
     */
    @RequestMapping("/getAllUserOrder")
    public MassageJsons getAllUserOrder(String order_code,Integer order_state, Integer pages, Integer pageSize){
        List<UserOrder> list = null;
        try {
            /*start:就是当前页的起始索引,pageSize就是每页的条数
            pages:就是当前页
            */
            int start=(pages-1)*pageSize;
            list=userOrderServic.getAllUserOrder(order_code,order_state,start,pageSize);
            return new MassageJsons("0","请求成功",list,userOrderDao.getUserOrderCount(order_code,order_state));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
